<?php

	function insertMap(
		$account_id
			,$p_map_type
			,$p_map_lat
			,$p_map_long
			,$p_map_title
	
	){
		mysql_query("
			INSERT INTO TB_MAP(
				ACCOUNT_ID
					,MAP_TYPE
					,MAP_LAT
					,MAP_LONG
					,MAP_TITLE
	
			)VALUES(
				'".$account_id."'
					,'".$p_map_type."'
					,'".$p_map_lat."'
					,'".$p_map_long."'
					,'".$p_map_title."'
	
			)	
		")or die(mysql_error());
		return true;
	}
	
	function updateMap(
		$p_account_id
			,$p_map_type
			,$p_map_lat
			,$p_map_long
			,$p_map_title
	
	){
		mysql_query("
			UPDATE TB_MAP 
			SET	MAP_LAT='".$p_map_lat."'
					,MAP_LONG='".$p_map_long."'
					,MAP_TITLE='".$p_map_title."'
	
			WHERE ACCOUNT_ID =  '".$p_account_id."' AND MAP_TYPE='".$p_map_type."'
		") or die (mysql_error());
	}

	function checkIsExistsMap ($p_account_id , $p_map_type ){
		$sql = " SELECT MAP_LONG, MAP_LAT
				FROM TB_MAP
				WHERE ACCOUNT_ID = '".$p_account_id."' AND MAP_TYPE = '".$p_map_type."'";
		$rs = mysql_query ($sql) or die (mysql_error());
		if ($arr = mysql_fetch_assoc($rs)){
			return true;
		}
		return false;
	}
	function getAllMap($p_where_clause,$p_offset,$p_num_row,$p_order_by=" ACCOUNT_ID DESC "){
		$rs = mysql_query("
		SELECT 
			ACCOUNT_ID
				,MAP_TYPE
				,MAP_LAT
				,MAP_LONG
				,MAP_TITLE

		FROM TB_MAP	
		WHERE 1 ".$p_where_clause."		
		ORDER BY ".$p_order_by."
		LIMIT ".$p_offset.",".$p_num_row."
		")or die(mysql_error());
		return $rs;
	}

	function getSingerMap($p_account_id){
		$rs = mysql_query("
		SELECT 
			ACCOUNT_ID
				,MAP_TYPE
				,MAP_LAT
				,MAP_LONG
				,MAP_TITLE

		FROM TB_MAP	
		WHERE ACCOUNT_ID =  '".$p_account_id."'		
		")or die(mysql_error());
		return $rs;
	}